<template>
  <div ref="vditor" id="vditor">
  </div>
</template>

<script>
import Vditor from "vditor"
import "vditor/dist/index.css"
export default {
  name: "MarkdownViewer",
  props: {
    mdText: String
  },
  methods: {
    async initEditor() {
      const previewElement = document.getElementById('vditor')
      console.log("md查看初始化")
      console.log(this.mdText)
      await Vditor.preview(previewElement, this.mdText)
    }
  },
  mounted() {
    this.initEditor()
  }
}
</script>

<style scoped>

</style>
